<template>
  <view style="padding: 24rpx;">
    <view class="form" v-for="(item, index) in list" :key="index">
      <view class="form-item">
        <view class="form-item-left">编号</view>
        <view class="form-item-right">{{ item.out_trade_no }}</view>
      </view>
      <view class="form-item">
        <view class="form-item-left">券包名称</view>
        <view class="form-item-right">{{ item.coupon_name }}</view>
      </view>
      <view class="form-item">
        <view class="form-item-left">券包数量</view>
        <view class="form-item-right">{{ item.stock }}</view>
      </view>
      <view class="form-item">
        <view class="form-item-left">券包金额</view>
        <view class="form-item-right">{{ item.price }}</view>
      </view>
      <view class="form-item">
        <view class="form-item-left">补贴后金额</view>
        <view class="form-item-right">{{ item.back_price }}</view>
      </view>
      <view class="form-item">
        <view class="form-item-left">到期时间</view>
        <view class="form-item-right">{{item.expire_time}}</view>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        list: [],
        userInfo: {},
        type:''
      }
    },
    onLoad(options) {
      if (options.type) {
        this.type = parseInt(options.type)
        if (this.type == 1) {
          uni.setNavigationBarTitle({
            title: '停车券包'
          })
        }
        if (this.type == 2) {
          uni.setNavigationBarTitle({
            title: '加油卡券包'
          })
        }
      }
    },
    onShow() {
      this.userInfo = vk.getVuex('$user.userInfo')
      this.getList()
    },
    methods: {
      getList() {
        uni.showLoading({
          title: '加载中...'
        })
        vk.callFunction({
          url: 'user/kh/contractList',
          data: {
            user_id: this.userInfo._id,
            type: this.type
          },
          success: (res) => {
            uni.hideLoading()
            this.list = res.rows
          }
        })
      }
    }
  }
</script>

<style lang="scss">
.form {
    padding: 32rpx;
    width: 638rpx;
    background-color: #fff;
    border-radius: 8rpx;
    margin-top: 24rpx;

    &-item {
      display: flex;
      align-items: center;
      height: 88rpx;

      &-left {
        color: #5A5A5A;
        font-family: PingFang SC;
        font-size: 28rpx;
        font-style: normal;
        font-weight: 400;
        width: 218rpx;
      }

      &-right {
        flex: 1;
        color: #000;
        font-family: PingFang SC;
        font-size: 28rpx;
        font-style: normal;
        font-weight: 400;
      }
    }
  }
</style>
